<?php
if( ! defined('BASEPATH')) exit('No direct script access allowed');

class Comments extends CI_Controller
{
	function __construct()
	{
		parent::__construct();
		// check if user logged in
		if(!$this->ion_auth->logged_in()){
			redirect('auth/login');	
		}
		$this->load->model('founder/comment_model');		
		$this->load->library('form_validation');
	}
	
	public function index(){
		$data['projects'] = $this->comment_model->get_all_projects();
		
		$meta['page_title']= "All comments";		
		
		$this->load->view('common/header', $meta);
		$this->load->view('founder/comments',$data);		
		$this->load->view('common/footer');
	}
	
	public function get_tasks($id = NULL){
	$tasks = $this->comment_model->get_tasks_by_projectid($_REQUEST['id']);
	
	foreach($tasks as $task){
		echo '<option value="'.$task->id.'">'.$task->title.'</option>';
		}
		
	}	
	
	public function get_task($id = NULL){	
	return $tasks = $this->comment_model->get_tasks_by_projectid($id);	
	}
	
	public function get_comments(){	
	
		$data['comments'] = $this->comment_model->all_comments($_REQUEST['Task_id']);		
		$this->load->view('founder/comments_ajax',$data);
	}
	
}

?>